import 'dart:async';

import 'package:get/get.dart';
import 'package:mtf/app/utils/cache/AppCahche.dart';
import 'package:mtf/app/utils/cache/CacheUtil.dart';

import '../../routes/app_pages.dart';
/**
 * GetX Template Generator - fb.com/htngu.99
 * */

class startController extends GetxController {
  var _obj = ''.obs;

  set obj(value) => _obj.value = value;

  get obj => _obj.value;

  @override
  void onInit() {
    super.onInit();
    print("startControlleronInit");
    // startTimer();
  }

  @override
  void onReady() {
    print("startControlleronInit");
    super.onReady();
  }

  late Timer timer;
  int _countValue = 2; // 用于记录计时的变量
  void startTimer() {
    // Timer.periodic方法可以反复执行，这里设置执行周期为1s
    timer = Timer.periodic(const Duration(seconds: 1), (timer) {
      print("_countValue${_countValue}");
      _countValue -= 1;
      if (_countValue < 0) {
        timer.cancel();
        // if(AppCache.isLogin()){
        //   Get.offNamed(Routes.HOME);
        // }else{
        //   Get.offNamed(Routes.LOGIN);
        // }
        Get.offNamed(Routes.HOME);
      }
    });
  }
}
